package com.resource.homeworkmanage.controller;

import java.util.Arrays;
import java.util.Map;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.resource.common.utils.PageUtils;
import com.resource.common.utils.R;
import com.resource.homeworkmanage.entity.TWorkInformationDetailEntity;
import com.resource.homeworkmanage.service.TWorkInformationDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 作业详细信息表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-04-04 17:00:38
 */
@RestController
@RequestMapping("work/tworkinformationdetail")
public class TWorkInformationDetailController {
    @Autowired
    private TWorkInformationDetailService tWorkInformationDetailService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tWorkInformationDetailService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{workCode}")
    public R info(@PathVariable("workCode") String workCode){
		TWorkInformationDetailEntity tWorkInformationDetail = tWorkInformationDetailService.getOne(new QueryWrapper<TWorkInformationDetailEntity>().eq("work_code",workCode));

        return R.ok().put("tWorkInformationDetail", tWorkInformationDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TWorkInformationDetailEntity tWorkInformationDetail){
		tWorkInformationDetailService.save(tWorkInformationDetail);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TWorkInformationDetailEntity tWorkInformationDetail){
		tWorkInformationDetailService.update(tWorkInformationDetail,new QueryWrapper<TWorkInformationDetailEntity>().eq("work_code",tWorkInformationDetail.getWorkCode()));
        tWorkInformationDetailService.submitMessage(tWorkInformationDetail);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] workCodes){
		tWorkInformationDetailService.removeByIds(Arrays.asList(workCodes));

        return R.ok();
    }

}
